October 23, 2014

Outline

  • Conference impressions
    • Tutorials
    • Talks
  • Code snippets
    • Rcpp
  • Outlook

poster.png

Conference impressions

Tutorials

Tuesday

  • Rcpp and C++
  • ggplot2
  • Using spatial data
  • Classification with individual and ensemble trees
  • Interactive web graphics with R and googleVis
  • Cloud computing
morebooks.jpg books.jpg books1.jpg

Tutorials

ggplot2

  • written by Hadley Wickham
  • implementation of the grammar of graphics
  • combines the advantages of both base and lattice graphics
ggplot2.jpg

Conference

Wednesday to Friday

talk.jpg peopleout.jpg

Conference

Talks

  • Invited talks
    • Duncan Murdoch
    • Hadley Wickham
    • Steve Scott
  • Contributed talks
    • useR! Focus Sessions
    • useR! Lightning Talks
    • useR! Kaleidoscope
talk.jpg talkco.jpg

Conference

Poster sessions

  • Bioinformatics
  • Econometrics
  • Ecological modeling
  • Marketing
  • Public policy
  • Social sciences
  • Statistics
posterse.jpg poster2.jpg

Conference

Social life

tapas.jpg

tapass.jpg tapasco.jpg

Code snippets

Rcpp

  • written by Dirk Eddelbuettel and Romain François
  • seamless R and C++ integration
    • supports many R data types
    • provides typical R functions and C++ classes
seamless.png

Why use C++ integration in R?

Sometimes, R code is just not fast enough…

impatience

  • Loops that cannot be vectorized because subsequent iterations depend on previous ones
# Count interations

for (i in 1:10) {
  if (i == 1) {
    nIter <- i
  } else {
    nIter <- nIter + 1  
  }
}

  • Recursive function calls
# Fibonacci sequence

fibonacci <- function(x) {
  if (x < 2) {
    return(x)
  } else {
    return(fibonacci(x-1) + fibonacci(x-2))
  }
}

sapply(1:10, fibonacci)
##  [1]  1  1  2  3  5  8 13 21 34 55

An example: the sum function


  • Base-R approach
  • x <- 1:10000
    
    sum(x)
    ## [1] 50005000

    An example: the sum function


  • Custom R approach
  • sumR <- function(x) {
      
      total <- 0
      for (i in 1:length(x)) {
        total <- total + x[i]
      }
      
      return(total)
    }
    
    sumR(x)
    ## [1] 50005000

    An example: the sum function


  • Rcpp approach
  • library(Rcpp)
    
    cppFunction('double sumC(NumericVector x) {
                
      int n = x.size();
      double total = 0;
      
      for(int i = 0; i < n; ++i) {
        total += x[i];
      }
      
      return total;
    }')
    
    sumC(x)
    ## [1] 50005000

    An example: the sum function


  • Speed test
  • library(microbenchmark)
    
    microbenchmark(sum(x), sumR(x), sumC(x), times = 1000L)
    ## Unit: microseconds
    ##     expr      min        lq       mean    median        uq       max neval
    ##   sum(x)    9.636    9.9020   12.56125   12.1105   14.8710   184.714  1000
    ##  sumR(x) 3763.070 4019.4675 4391.46257 4155.5130 4576.7380 40767.704  1000
    ##  sumC(x)   20.820   22.3835   31.41349   31.9950   36.8205   284.987  1000

    Outlook

    user2015

    With invited talks by

    • Thomas Lumley (R Core Team)
    • Adrian Baddeley (spatstat)
    • Romain François (Rcpp)

    (see http://user2015.math.aau.dk/)

    Side note

    group_image Thank you for your attention!